function init() {
	// Connect to the SocketIO server to retrieve ongoing games.
	socket = io.connect();
	socket.on('gamesList', function(data) {
								 var ul = document.getElementById('lesParties');
								 ul.innerHTML='';
								 for(p in data.gamesList) {
								 var nomGame = data.gamesList[p];
									 var li = document.createElement('div'); 
									 li.className = "col-lg-2";
									 var div = document.createElement('button'); 
									 div.className="btn btn-primary btn-lg";
									 div.style.minHeight = "34px";
									 div.style.minWidth = "120px";
									 div.style.maxHeight = "34px";
									 div.style.maxWidth = "120px";
									 div.style.paddingTop = "5px";
									 div.setAttribute("onClick","remplir('"+ nomGame + "')");
									 li.style.paddingTop = "10px";
									 ul.appendChild( li );
									 li.appendChild( div );
									 div.appendChild( document.createTextNode( nomGame) );
									}
								}
			 );
	socket.emit('loginPage');
}

function remplir(nomPartie){
	
	document.getElementById('idGame').value = nomPartie;
	document.getElementById('nouvellePartie').submit();
	
}
